import json

demo_dict = {"city":"北京","name":"小明3"}
print(json.dumps(demo_dict))

json.dump(demo_dict,open("dict_str2.json","w"))

print(json.dumps(demo_dict,ensure_ascii=False))
